//获取当前时间
// var date = new Date();
// this.year = date.getFullYear(); //获取完整的年份(4位)
// this.living_time = this.publick.buor(date.getMonth() + 1) + '月' + this.publick.buor(date.getDate()) + '日'; //获取当前月份(0-11,0代表1月)
// this.one_time = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate()
// this.living_week = '今天' //获取当前星期X(0-6,0代表星期天)

// //获取明天时间
// date.setDate(date.getDate() + 1);
// this.end_time = this.publick.buor(date.getMonth() + 1) + '月' + this.publick.buor(date.getDate()) + '日'; //获取当前月份(0-11,0代表1月)
// this.end_week = this.publick.week(date.getDay()); //获取当前星期X(0-6,0代表星期天)
// this.two_time = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate()
//封装的公共函数
const publick = {
    //测试引入成功
    measurement:function(){
        console.log('你成功了哦！');
	},
	token:function(){
         return JSON.parse(localStorage.getItem("myself")).token;
	},
	//判断星期
	week: function(e) {
		var day = ''
		switch (e) {
			case 0:
				day = "星期天";
				break;
			case 1:
				day = "星期一";
				break;
			case 2:
				day = "星期二";
				break;
			case 3:
				day = "星期三";
				break;
			case 4:
				day = "星期四";
				break;
			case 5:
				day = "星期五";
				break;
			case 6:
				day = "星期六";
		}
		return day
	},
	//补0
	buor: function(e) {
		if (e < 10) {
			return ("0" + e)
		} else {
			return e
		}
    },
	//查询二维数组的下标
	two_dimension: function(arr, city) {
		var t = [];
		for (var i = 0; i < arr.length; i++) {
			for (var j = 0; j < arr[i].length; j++) {
				if (arr[i][j].label.indexOf(city) > -1) {
					t = [i, j, 0, 0];
					return t;
				}
			}
		}
	},
	//图片上传
	api: function() {
		// return "http://45.93.18.7:9501/api/client";
		return "http://117.34.80.233:9501/api/client";
	},
	//图片展示
	api_img: function() {
		// return 'http://45.93.18.7:9501/'
		return 'http://117.34.80.233:9501/'
	},
	//验证手机号
	isPhoneAvailable: function(number) {
		var phoneReg = /^1[3-578]\d{9}$/;
		if (phoneReg.test(number)) {
			return true;
		} else {
			return false;
		}
	},
	//将月/日转换成-
	date_zhuan(date) {
		// console.log(date.indexOf('月') == -1
		if(date.indexOf('月') == -1){
			return date;
		}else{
			var n = date.replace(/[\u4e00-\u9fa5]/gi, '-');
			var index = n.length - 1;
			n = n.substr(0, index);
			return n;
		}
	},
	//时间截取
	cut_time(t) {
		let time = t.substring(0, 10)
		return time
	},
	//时间换算天数
	day(one_day, two_day) {
		let oDate1 = new Date(two_day) 
		let oDate2 = new Date(one_day)
		let iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数 
		return iDays
	},
	//清除input空格
    clearinput(str){
		console.log(str.replace(/^\s+|\s+$/g,""))
	    return str.replace(/^\s+|\s+$/g,"");
	}
}
export {
	publick
}